package cn.sanxintong.utils.common;

import org.apache.commons.lang.StringUtils;

/**
 * 处理字符串的工具类
 * @author hxy
 *
 */
public class StrUtils {

	/**
	 * 替换下划线和把首字母转成大写
	 * @param str
	 * @return 
	 */
	public static String replaceUnderLineAndUpperCase(String str) {
		StringBuffer sb = new StringBuffer();
		sb.append(str);
		int count = sb.indexOf("_");
		while (count != 0) {
			int num = sb.indexOf("_", count);
			count = num + 1;
			if (num != -1) {
				char ss = sb.charAt(count);
				char ia = (char) (ss - 32);
				sb.replace(count, count + 1, ia + "");
			}
		}
		String result = sb.toString().replaceAll("_", "");
		return StringUtils.capitalize(result);
	}
}
